const ResultVo = require('../utils/ResultVo')
const LabelUserService = require('../service/LabelUserService')

class LabelUserController {
  async create(req, res, next) {
    const { userId, labelId } = req.body
    await LabelUserService.create({ userId, labelId }).catch(err => next(err))
    res.json(ResultVo.successNull())
  }

  async getLabelUserList(req, res, next) {
    const { userId } = req.query
    const result = await LabelUserService.findByUserId(userId).catch(err => next(err))
    res.json(ResultVo.success(result))
  }

  async removeLabelUser(req, res, next) {
    const { labelId, userId } = req.body
    const result = await LabelUserService.remove({labelId, userId}).catch(err => next(err))
    res.json(ResultVo.success(result))
  }
}

module.exports = new LabelUserController()